<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <!-- 引入ElementUI的样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<style>
    /*
           设置body样式

       */
    body{
        margin: 20px;/*设置上下左右空白距离为0*/
    }
</style>
<body>
<div id="index-box">
    <div style="margin: 20px;"></div>
    <el-form  status-icon label-width="100px" class="demo-ruleForm">
        <el-form-item label="姓名" >
            <el-input type="text" v-model="ruleForm.username" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="密码" >
            <el-input type="password" v-model="ruleForm.userpassword" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="submitForm">提交</el-button>
        </el-form-item>
    </el-form>
</div>

</body>
<script src="js/vue.min.js"></script>
<script src="js/axios.min.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="js/sweetalert2.js"></script>
<script>
    new Vue({
        el:'#index-box',
        data() {
            return {
                ruleForm: {
                    username: '',
                    userpassword: '',
                },

            };
        },
        methods: {
            submitForm() {
                axios.post('user/changePassword?username='+this.ruleForm.username+'&userpassword='+this.ruleForm.userpassword)
                .then(t=>{
                    let result =t.data;
                    console.log(t.data)
                    Swal.fire({
                        icon: 'success',//图标
                        title: result.message,//消息
                        showConfirmButton: false,//不显示确认按钮
                        timer: 1000,
                        willClose:()=>{
                            location.href="login.html";
                        }
                    });
                })
                .catch(err=>{
                    alert(err)
                })
            }
        },
        mounted(){
    }
    })
</script>
</html>